package com.annoncesautomobile.modele.concreteEntities;

import java.util.HashMap;
import java.util.Map;

public class Client {

	private int idClient;
	private String contrat;
	private String nom;
	private String adresse;
	private String cp;
	private String ville;
	private String tel1;
	private String tel2;
	private String email;
	private String contact;
	private String departement;
	private String departement_num;
	private String image;

	public int getIdClient() {
		return idClient;
	}
	public void setIdClient(int idClient) {
		this.idClient = idClient;
	}
	public String getContrat() {
		return contrat;
	}
	public void setContrat(String contrat) {
		this.contrat = contrat;
	}
	public String getNom() {
		return nom;
	}
	public void setNom(String nom) {
		this.nom = nom;
	}
	public String getAdresse() {
		return adresse;
	}
	public void setAdresse(String adresse) {
		this.adresse = adresse;
	}
	public String getCp() {
		return cp;
	}
	public void setCp(String cp) {
		this.cp = cp;
	}
	public String getVille() {
		return ville;
	}
	public void setVille(String ville) {
		this.ville = ville;
	}
	public String getTel1() {
		return tel1;
	}
	public void setTel1(String tel1) {
		this.tel1 = tel1;
	}
	public String getTel2() {
		return tel2;
	}
	public void setTel2(String tel2) {
		this.tel2 = tel2;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getContact() {
		return contact;
	}
	public void setContact(String contact) {
		this.contact = contact;
	}
	public String getDepartement() {
		return departement;
	}
	public void setDepartement(String departement) {
		this.departement = departement;
	}
	public String getDepartement_num() {
		return departement_num;
	}
	public void setDepartement_num(String departement_num) {
		this.departement_num = departement_num;
	}	
	public String getImage() {
		return image;
	}
	public void setImage(String image) {
		this.image = image;
	}
	public Client(int idClient, String contrat, String nom, String adresse,
			String cp, String ville, String tel1, String tel2, String email,
			String contact, String departement, String departement_num, String image) {
		super();
		this.idClient = idClient;
		this.contrat = contrat;
		this.nom = nom;
		this.adresse = adresse;
		this.cp = cp;
		this.ville = ville;
		this.tel1 = tel1;
		this.tel2 = tel2;
		this.email = email;
		this.contact = contact;
		this.departement = departement;
		this.departement_num = departement_num;
		this.image = image;
	}



	@Override
	public String toString() {
		return "Client [idClient=" + idClient + ", contrat=" + contrat
				+ ", nom=" + nom + ", adresse=" + adresse + ", cp=" + cp
				+ ", ville=" + ville + ", tel1=" + tel1 + ", tel2=" + tel2
				+ ", email=" + email + ", contact=" + contact
				+ ", departement=" + departement + ", departement_num="
				+ departement_num + ", image=" + image + "]";
	}
	public Client(String fromXML)
	{
		String[] fields = fromXML.split("SPLIT_CHAR1_SPLIT_CHAR2");
		Map<String, String> values = new HashMap<String, String>();

		for(String i : fields)
		{
			if(!i.equals(""))
			{
				System.out.println(i);
				String[] splitted = i.split("=");

				String key = splitted[0];
				String value = "";
				if(splitted.length == 2)
				{
					value = splitted[1];
				}

				values.put(key, value);
			}
		}
		this.idClient = Integer.parseInt(values.get("id"));
		this.contrat = values.get("contrat");
		this.nom = values.get("nom");
		this.adresse = values.get("adresse");
		this.cp = values.get("cp");
		this.ville = values.get("ville");
		this.tel1 = values.get("tel1");
		this.tel2 = values.get("tel2");
		this.email = values.get("email");
		this.contact = values.get("contact");
		this.departement = values.get("departement");
		this.departement_num = values.get("departement_num");
		this.image = values.get("image");
	}

}
